import request from '@/utils/request'

/**
 * 获取搜索结果
 * @param  {[type]} data [description]
 * @return {[type]}        [description]
 */
export function getSearch(data) {
  return request({
    url: 'http://36.152.9.59:8090/api/site/search',
    method: 'post',
    data,
    transformRequest: [function (data) {
      // Do whatever you want to transform the data
      let ret = ''
      for (let it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}


/**
 * 获取物种详情数据
 * @param  {[string]} id [description]
 * @return {[type]}        [description]
 */
export function getDetail(id) {
  return request({
    url: `http://36.152.9.59:8090/api/site/species_card/${id}`,
    method: 'get',
  })
}
